<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">
<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span id="flowsetname"></span><div class="move_title"></div><?php include "../public/sub.php";?></div></div>
    <div class="main-container">

        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits">
                        <span>基本信息</span>
                        <button type="button" onclick="openPage('../public/choose_contract_yang.php?page=contract_cai','80%','80%')" class="layui-btn layui-btn-sm btn-dark marginr5" style="float: right;margin-top: 11px;margin-right: 10px!important;">引用模板</button>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="enginid" class="layui-input enginid" onclick="openPage('../public/choose_engin.php?dom=enginid&page=contract_cai','80%','80%')">
                            <div class="choose_div" id="enginid" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_engin.php?dom=enginid&page=contract_cai','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>合同名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>合同状态</label>
                        <div class="layui-input-block">
                            <select id="state" name="state" lay-filter="state" ></select>
                            <p class="error" id="state_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">合同编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" id="number" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>合同年份</label>
                        <div class="layui-input-block">
                            <select id="year" name="year" lay-filter="year" ></select>
                            <p class="error" id="year_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>合同类型</label>
                        <div class="layui-input-block">
                            <select id="caihetype" name="caihetype" lay-filter="caihetype"></select>
                            <p class="error" id="caihetype_error" style="margin: 0;"></p>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">合同属性</label>
                        <div class="layui-input-block">
                            <div id="caiheshu"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>供应方(乙方)</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="gonger" class="layui-input gonger" onclick="openPage('../public/choose_dealcom.php?dom=gonger&page=contract_cai','80%','80%')">
                            <div class="choose_div" id="gonger" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=gonger&page=contract_cai','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>采购方(甲方)</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=caier&type=dept&dept=chan&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="caier"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=caier&type=dept&dept=chan&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="caier_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">乙方联系人</label>
                        <div class="layui-input-block">
                            <input type="text" name="gonguser" id="gonguser" placeholder="请输入" clearable  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">我方签订人</label>
                        <div class="layui-input-block">
                            <input type="text" name="myer" id="myer" placeholder="请输入" clearable  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">乙方联系方式</label>
                        <div class="layui-input-block">
                            <input type="text" name="gongtel" id="gongtel" placeholder="请输入" clearable  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">签订日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="qiandt" id="qiandt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>合同金额(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="money" id="money" placeholder="请输入" disabled autocomplete="off" class="layui-input moneyinput disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">税率(%)</label>
                        <div class="layui-input-block">
                            <input type="number" name="rate" id="rate" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">合同开始日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="startdt" id="startdt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">合同结束日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="enddt" id="enddt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">质保金比例(%)</label>
                        <div class="layui-input-block">
                            <input type="number" name="zhirate" id="zhirate" placeholder="请输入" clearable  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">质保金金额(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhifee" id="zhifee" placeholder="自动计算(合同金额*质保金比例)" disabled autocomplete="off" class="layui-input disabled moneyinput">
                        </div>
                    </div>
                </div>
            </div>



            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">结算方式</label>
                        <div class="layui-input-block">
                            <textarea id="settle" name="settle" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">支付条件</label>
                        <div class="layui-input-block">
                            <textarea id="zhitiao" name="zhitiao" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">主要条款</label>
                        <div class="layui-input-block">
                            <textarea id="clause" name="clause" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">违约责任</label>
                        <div class="layui-input-block">
                            <textarea id="viola" name="viola" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <?php include '../public/upinfo.php'?>
        </div>



        <div class="block-generic" id="caiDiv" budgetid="0">
            <div class="layui-form-item height_auto">
                <div class="short_table_list" key="1">
                    <div class="opt-btn-group">
                        <div><span>合同明细</span></div>
                        <div>
                            <button type="button" id="list_xuan" onclick="choose_engin_budget_list()" class="layui-btn layui-btn-sm layui-btn-primary layui-hide mingxibtn">从预算明细选择</button>
                            <button type="button" id="list_ctrlv" onclick="ctrlv_data_open()" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn">粘贴新增</button>
                            <button type="button" id="list_dao" onclick="import_list()" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn">Excel导入</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_add_row">插入行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_row">删除行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_all">删除全部</button>
                        </div>
                    </div>
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th width="45">序号</th>
                            <th class="layui-hide"><text>*</text>成本科目</th>
                            <th class="layui-hide"><text>*</text>预算项</th>
                            <th><text>*</text>名称及规格</th>
                            <th><text>*</text>单位</th>
                            <th><text>*</text>采购数量</th>
                            <th><text>*</text>采购单价(元)</th>
                            <th><text>*</text>采购金额(元)</th>
                            <th>备注</th>
                        </tr>
                        </thead>
                        <tbody class="short_table_tbody" id="cai_list"></tbody>
                    </table>
                    <div class="listerror">提示：<span></span></div>
                </div>
            </div>
        </div>



    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;
    $("#commentForm").validate({
        rules: {
            name: {required: true},
        },
        messages:{
            name: {required: "请输入"},
        }
    });

    function choose_engin_budget_list(obj){
        var budgetid = $("#caiDiv").attr('budgetid');
        openPage('../public/choose_engin_budget_list.php?page=contract_cai&budgetid='+budgetid,'80%','80%');
    }

    function choose_engin_budget_list_one(obj){
        var domkey = $(obj).parents('tr').index();
        var budgetid = $("#caiDiv").attr('budgetid');
        openPage('../public/choose_engin_budget_list.php?choose_type=radio&page=contract_cai_one&budgetid='+budgetid+'&domkey='+domkey,'80%','80%');
    }

    function import_list() {
        openPage('../public/import.php?reveal=contract_cai@importdata', '770px', '490px');
    }

    var pub_caiheshu;

    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();
        facade.ajax({type: 'get', url: ask_contract_cai_edit, data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;

                var engininfo = res.data.engininfo;
                if(engininfo){
                    set_choose_btn('enginid',engininfo.id,engininfo.name);
                }

                $("#name").val(data.name);
                $("#number").val(data.number);
                $("#gonger").val(data.gonger);
                $("#gonguser").val(data.gonguser);
                $("#myer").val(data.myer);
                $("#gongtel").val(data.gongtel);
                $("#qiandt").val(data.qiandt);
                $("#money").val(data.money);
                $("#rate").val(data.rate);
                $("#startdt").val(data.startdt);
                $("#enddt").val(data.enddt);
                $("#zhirate").val(data.zhirate);
                $("#zhifee").val(data.zhifee);
                $("#settle").val(data.settle);
                $("#zhitiao").val(data.zhitiao);
                $("#clause").val(data.clause);
                $("#viola").val(data.viola);
                $("#explain").val(data.explain);

                $("#caiDiv").attr('budgetid',data.budgetid);



                set_choose_btn('gonger',data.gonger,data.gonger);
                if(data.caier_info.length > 0){
                    tan_tags_init('#caier', data.caier_info);
                }

                var state_str = '<option value="">请选择</option>';
                var state = res.data.state;
                for (var key in state){
                    if(data.state == key){
                        state_str += '<option value="'+key+'" selected>'+state[key]+'</option>';
                    }else{
                        state_str += '<option value="'+key+'">'+state[key]+'</option>';
                    }
                }
                $("#state").html(state_str);

                var year_str = '<option value="">请选择</option>';
                var year = res.data.year;
                for (var key in year){
                    if(data.year == year[key]){
                        year_str += '<option value="'+year[key]+'" selected>'+year[key]+'</option>';
                    }else{
                        year_str += '<option value="'+year[key]+'">'+year[key]+'</option>';
                    }
                }
                $("#year").html(year_str);

                var caihetype_str = '<option value="">请选择</option>';
                var caihetype = res.data.caihetype;
                for (var key in caihetype){
                    if(data.caihetype == key){
                        caihetype_str += '<option value="'+key+'" selected>'+caihetype[key]+'</option>';
                    }else{
                        caihetype_str += '<option value="'+key+'">'+caihetype[key]+'</option>';
                    }
                }
                $("#caihetype").html(caihetype_str);


                pub_caiheshu = res.data.caiheshu;
                xmselect_dan('caiheshu', pub_caiheshu, data.caiheshu);



                var listAddStr = '';
                listAddStr += '<tr>';
                listAddStr += '<td style="width: 45px">1</td>';
                listAddStr += '<td class="layui-hide">';
                listAddStr += '<input type="text" onclick="choose_engin_budget_list_one(this)" readonly placeholder="请选择" id="0" listid="0" class="layui-input subname disabled">';
                listAddStr += '</td>';
                listAddStr += '<td class="layui-hide"><input type="text" disabled class="layui-input guiname disabled"></td>';
                listAddStr += '<td><input type="text" class="layui-input name"></td>';
                listAddStr += '<td><input type="text" class="layui-input unit"></td>';
                listAddStr += '<td><input type="number" class="layui-input num"></td>';
                listAddStr += '<td><input type="number" class="layui-input price"></td>';
                listAddStr += '<td><input type="number" disabled class="layui-input money disabled"></td>';
                listAddStr += '<td><input type="text" class="layui-input explain"></td>';
                listAddStr += '</tr>';
                short_table_opt_func(listAddStr, 1);

                var list = res.data.list;
                if(list.length > 0){
                    var str = '';
                    for (var key in list){
                        var nums = parseInt(key)+1;
                        str += '<tr>';
                        str += '<td style="width: 45px">'+nums+'</td>';
                        str += '<td class="layui-hide">';
                        str += '<input type="text" onclick="choose_engin_budget_list_one(this)" readonly value="'+list[key].subname+'" placeholder="请选择" id="'+list[key].id+'" listid="'+list[key].listid+'" class="layui-input subname disabled">';
                        str += '</td>';
                        str += '<td class="layui-hide"><input type="text" disabled class="layui-input guiname disabled" value="'+list[key].guiname+'"></td>';
                        str += '<td><input type="text" class="layui-input name" key="'+list[key].id+'" value="'+list[key].name+'"></td>';
                        str += '<td><input type="text" class="layui-input unit" value="'+list[key].unit+'"></td>';
                        str += '<td><input type="number" class="layui-input num" value="'+list[key].num+'"></td>';
                        str += '<td><input type="number" class="layui-input price" value="'+list[key].price+'"></td>';
                        str += '<td><input type="number" class="layui-input money disabled" disabled value="'+list[key].money+'"></td>';
                        str += '<td><input type="text" class="layui-input explain" value="'+list[key].explain+'"></td>';
                        str += '</tr>';
                    }
                    $("#cai_list").html(str);
                }
                update_refresh_row_func();



                initParseMoney();
                public_upload_file_load('upload_files', res.data.files);
                render_from();
            }
        });

        form.on('select(year)', function(data){
            if(data.value == ''){
                $('#year_error').show().text('请选择');
                $('#year_error').parent().find('input').addClass('select_error');
            }else{
                $('#year_error').hide();
                $('#year_error').parent().find('input').removeClass('select_error');
            }
        });
        form.on('select(caihetype)', function(data){
            if(data.value == ''){
                $('#caihetype_error').show().text('请选择');
                $('#caihetype_error').parent().find('input').addClass('select_error');
            }else{
                $('#caihetype_error').hide();
                $('#caihetype_error').parent().find('input').removeClass('select_error');
            }
        });

        form.on('select(state)', function(data){
            if(data.value == ''){
                $('#state_error').show().text('请选择');
                $('#state_error').parent().find('input').addClass('select_error');
            }else{
                $('#state_error').hide();
                $('#state_error').parent().find('input').removeClass('select_error');
            }
        });

        form.on('submit(add)', function(data){

            data.field.gonger = get_choose_val('gonger');
            data.field.caier = tan_tags_getvalue("#caier", 'dept');
            data.field.enginid = get_choose_val('enginid');

            var validRes = $("#commentForm").valid();

            formValid('enginid');
            if(data.field.enginid == undefined || !data.field.enginid){
                validRes = false;
            }

            if(data.field.state == ''){
                $('#state_error').show().text('请选择');
                $('#state_error').parent().find('input').addClass('select_error');
                validRes = false;
            }else{
                $('#state_error').hide();
                $('#state_error').parent().find('input').removeClass('select_error');
            }

            if(data.field.year == ''){
                $('#year_error').show().text('请选择');
                $('#year_error').parent().find('input').addClass('select_error');
                validRes = false;
            }else{
                $('#year_error').hide();
                $('#year_error').parent().find('input').removeClass('select_error');
            }

            if(data.field.caihetype == ''){
                $('#caihetype_error').show().text('请选择');
                $('#caihetype_error').parent().find('input').addClass('select_error');
                validRes = false;
            }else{
                $('#caihetype_error').hide();
                $('#caihetype_error').parent().find('input').removeClass('select_error');
            }

            formValid('gonger');
            if(data.field.gonger == undefined || !data.field.gonger){
                validRes = false;
            }

            if(!data.field.caier){
                $("#caier").parents('.tanxian').addClass('tanerror');
                $('#caier_tanerror').text('请选择');
                validRes = false;
            }else{
                $("#caier").parents('.tanxian').removeClass('tanerror');
                $('#caier_tanerror').text('');
            }

            if(!validRes){return false;}


            var budgetid = $("#caiDiv").attr('budgetid');

            var list = [''];
            try {
                $('#cai_list tr').each(function (i) {
                    var id = $(this).find('.name').attr('key') || 0;
                    var listid = $(this).find('.subname').attr('listid');
                    var name = $(this).find('.name').val();
                    var unit = $(this).find('.unit').val();
                    var num = $(this).find('.num').val();
                    var price = $(this).find('.price').val();
                    var money = $(this).find('.money').val();
                    var explain = $(this).find('.explain').val();

                    var index = i + 1;
                    if(!listid && !name && !unit && num=='' && price=='' && !money && !explain){
                        return false;
                    }

                    if(budgetid > 0){
                        if(!listid){
                            throw new Error('第'+index+'行，请选择成本科目');
                        }
                    }
                    if(!name){
                        throw new Error('第'+index+'行，请输入名称及规格');
                    }
                    if(!unit){
                        throw new Error('第'+index+'行，请输入单位');
                    }
                    if(!num){
                        throw new Error('第'+index+'行，请输入采购数量');
                    }
                    if(!price){
                        throw new Error('第'+index+'行，请输入采购单价');
                    }


                    var chongKey = check_chongfu(i, name, unit, price);
                    if(chongKey){
                        throw new Error('第'+chongKey+'行'+'与第'+index+'行，数据重复');
                    }


                    list.push({
                        id:id,
                        listid:listid,
                        name:name,
                        unit:unit,
                        num:num,
                        price:price,
                        money:money,
                        explain:explain,
                    });
                });
            } catch(e) {
                $(".listerror").find('span').text(e.message);
                $(".listerror").show();
                return false;
            }
            $(".listerror").hide();
            data.field.list = list;


            data.field.id = param_id;
            data.field.files = public_upload_file_value('upload_files');
            data = parseMoney(data);

            facade.ajax({url: ask_contract_cai_edit, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });
            return false;
        });

    });



    //检测重复
    function check_chongfu(index, name, unit, price){
        try {
            $('#list_list tr').each(function (i) {
                var cur_name = $(this).find('.name').val();
                var cur_unit = $(this).find('.unit').val();
                var cur_price = $(this).find('.price').val();
                if(index != i){
                    if(name == cur_name && unit == cur_unit && price == cur_price){
                        throw new Error(i+1);
                    }
                }
            });
        } catch(e) {
            return e.message;
        }

        return 0;
    }


    $('#cai_list').on('input propertychange','.num,.price',function () {
        jisuan_money_all();
    });
    function jisuan_money_all() {
        var allmoney = 0;
        $('#cai_list tr').each(function (i) {
            var num = parseValidNum($(this).find('.num').val(), 3);
            var price = parseValidNum($(this).find('.price').val());
            var money = (num * price).toFixed(2);
            $(this).find('.money').val(money);

            allmoney = parseFloat(allmoney) + parseFloat(money);
        });
        $("#money").val(allmoney);
        initParseMoney();

        jisuan_money_other();
    }





    $("#zhirate").on('input propertychange',function () {
        jisuan_money_other();
    });
    function jisuan_money_other() {
        var money = parseValidNum($("#money").val());
        var zhirate = parseValidNum($("#zhirate").val());
        var zhifee = money * zhirate / 100;
        $("#zhifee").val(parseFormatNum(zhifee,2));
    }





    function choose_gonger_delete() {
        $("#gonguser").val('');
        $("#gongtel").val('');
    }


    function set_list_layout() {
        var budgetid = $("#caiDiv").attr('budgetid');
        if(budgetid > 0){
            $("#caiDiv table tr th, #caiDiv table tr td").removeClass('layui-hide');
            $("#list_ctrlv").addClass('layui-hide');
            $("#list_dao").addClass('layui-hide');
            $("#list_xuan").removeClass('layui-hide');
        }else{
            $("#caiDiv table tr th:nth-child(2)").addClass('layui-hide');
            $("#caiDiv table tr th:nth-child(3)").addClass('layui-hide');
            $("#caiDiv table tr td:nth-child(2)").addClass('layui-hide');
            $("#caiDiv table tr td:nth-child(3)").addClass('layui-hide');
            $("#list_ctrlv").removeClass('layui-hide');
            $("#list_dao").removeClass('layui-hide');
            $("#list_xuan").addClass('layui-hide');
        }
    }


    function update_refresh_row_func() {
        render_date();
        set_list_layout();
        jisuan_money_all();

        $.each($("#cai_list").children('tr'),function (key,val) {
            $(this).children('td:first-child').html(key+1);
        });

        setTimeout(function () {
            $(".short_table_list table tbody tr").click(function () {
                $(".short_table_list table tbody tr").removeClass('line-row');
                $(".short_table_list table tbody tr").attr('sle','');
                $(this).addClass('line-row');
                $(this).attr('sle','sle');
            });
        },1000);
    }









    var ctrlv_field_name = [
        {field: 'name', name:'名称及规格'},
        {field: 'unit', name:'单位'},
        {field: 'num', name:'采购数量',type:'number'},
        {field: 'price', name:'采购单价',type:'number'},
        {field: 'explain', name:'备注'},
    ];
    function ctrlv_data_show(list) {
        if(list.length > 0){
            var nums = $("#cai_list tr").length;
            for (var key in list){
                var str = '';
                nums++;
                str += '<tr>';
                str += '<td style="width: 45px">'+nums+'</td>';
                str += '<td class="layui-hide">';
                str += '<input type="text" onclick="choose_engin_budget_list_one(this)" listid="0" readonly placeholder="请选择" class="layui-input subname disabled">';
                str += '</td>';
                str += '<td class="layui-hide"><input type="text" disabled class="layui-input guiname disabled"></td>';
                str += '<td><input type="text" class="layui-input name" value="'+list[key].name+'"></td>';
                str += '<td><input type="text" class="layui-input unit" value="'+list[key].unit+'"></td>';
                str += '<td><input type="number" class="layui-input num" value="'+list[key].num+'"></td>';
                str += '<td><input type="number" class="layui-input price" value="'+list[key].price+'"></td>';
                str += '<td><input type="number" class="layui-input money disabled" disabled></td>';
                str += '<td><input type="text" class="layui-input explain" value="'+list[key].explain+'"></td>';
                str += '</tr>';
                $("#cai_list").append(str);
            }
        }
        update_refresh_row_func()

        render_date();
        render_from();
    }
</script>
</body>
</html>
